package cn.wei.sdd.core.controller.admin;


import cn.wei.common.result.R;
import cn.wei.sdd.base.util.JwtUtils;
import cn.wei.sdd.core.pojo.query.PackOrdersQuery;
import cn.wei.sdd.core.pojo.vo.CheckOrdersVO;
import cn.wei.sdd.core.service.PackOrdersService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 订单打包记录表 前端控制器
 * </p>
 *
 * @author Wei
 * @since 2021-10-31
 */
@RestController
@Api(tags = "订单打包管理")
@RequestMapping("/admin/core/packOrders")
public class AdminPackOrdersController {
    @Autowired
    private PackOrdersService packOrdersService;

    @ApiOperation("管理员验收")
    @GetMapping("check/{packNo}/{checkCode}")
    public R check(
            @PathVariable("checkCode") String checkCode,
            @PathVariable("packNo") String packNo,

            HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);

        packOrdersService.check(packNo,checkCode,userId);
        return R.ok().message("验收成功");

    }

//    @ApiOperation("获取打包记录列表")
//    @GetMapping("packOrdersList/{page}/{limit}")
//    public R listPage(
//            @ApiParam("当前页码")
//            @PathVariable(value = "page",required = true) Long page,
//            @ApiParam("页码记录数")
//            @PathVariable(value = "limit",required = true) Long limit,
//            @ApiParam(value = "查询对象",required = false)
//            PackOrdersQuery packOrdersQuery){
//        Page<CheckOrdersVO> pageParam = new Page<>(page, limit);
//
//        return R.ok();
//    }
//    @ApiOperation("获取待验收的打包订单")
//    @GetMapping("getCheckOrders")
//    public R getCheckOrders(HttpServletRequest request){
//        String token = request.getHeader("token");
//        Long userId = JwtUtils.getUserId(token);
//
//        List<CheckOrdersVO> list= packOrdersService.getCheckOrders(userId);
//        return R.ok().data("list",list);
//    }
}

